package admin

import (
	"gitee.com/yangguoliang001/go-gin-vue3/services/adminService"
	"github.com/gin-gonic/gin"
	"github.com/go-redis/redis/v7"
	"gorm.io/gorm"

	"go.uber.org/zap"
)

type Controller interface {
	Login(c *gin.Context)
	Logout(c *gin.Context)
	QueryAdminByUsername(c *gin.Context)
	QueryAdminList(c *gin.Context)
	AddAdmin(c *gin.Context)
	DisabledAdmin(c *gin.Context)
	DeletedAdmin(c *gin.Context)

	QueryAdminMenu(c *gin.Context)
	EditAdminMenu(c *gin.Context)
}

type adminController struct {
	logger       *zap.Logger
	cache        *redis.Client
	adminService *adminService.AdminService
}

func New(logger *zap.Logger, db *gorm.DB, cache *redis.Client) Controller {
	return &adminController{
		logger:       logger,
		cache:        cache,
		adminService: adminService.New(db, cache),
	}
}
